package cac.fenjian.resource.mssslshelves.dao;

import cac.fenjian.resource.MsSslShelves.dto.MsSslShelvesDTO;
import cac.fenjian.resource.MsWpTool.dto.MsWpToolBasicDTO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface MsSslShelvesDao {

    /**
     * 判断是否移库
     * @return
     */
    public HashMap isNeedMove(@Param("map")Map map);

    //判断移库位是否存在未完成任务
    public List<HashMap> searchDependShelvesPallet(@Param("map")Map map);

    //判断该托盘是否存在未完成的任务
    public List<HashMap> isFinishTask(@Param("map")Map map);
    /**
     * 查询具体货位
     * @param palletCode
     * @param startCode
     * @param palletHeight
     * @return
     */
    public String getSpaceCode(@Param("palletCode") String palletCode,@Param("startCode")String startCode,@Param("palletHeight")int palletHeight);

    /**
     * 获取双深位内部货位绑定的外部阻挡货位
     * @param DependLocation
     * @return
     */
    public String getDependLocation(@Param("DependLocation") String DependLocation);

    /**
     * 获取当前巷道可以储位，提供移库
     * @param map
     * @return
     */
    public String getAvailableLocation(@Param("map")Map map,@Param("list")String list);

    /**
     * 获取当前巷道剩余储位，提供移库
     * @param map
     * @return
     */
    public String getRestLocation(@Param("map")Map map,@Param("list")String list);

    /**
     * 查询巷道,扫描位
     * @return
     */
    public String getRoadWay(@Param("location") int location,@Param("count")int count);

    /**
     * 直接在扫描位获取具体货位，根据具体货位获取巷道
     * @param location
     * @param count
     * @return
     */
    public HashMap getShelves(@Param("location") int location,@Param("count")int count,
                              @Param("palletHeight")String palletHeight,
                              @Param("startCode")Object startCode,@Param("isTest")Boolean isTest);

    //5-4
//    public int searchShelveCodeOut(@Param("shelvesCode")String shelvesCode);

    /**
     * 堆垛机调用接口时，根据托盘号获取扫描位分配给该托盘的具体货位
     * @param palletCode
     * @return
     */
    public String getCorrespondingShelves(@Param("palletCode")String palletCode);

    public String checkSpace(@Param("spaceCode")String spaceCode);
    //接收wcs反馈信息任务启动
    public int taskStartCallBack(@Param("map")Map map,@Param("param")String param);
    //接收wcs反馈信息任务完成
    public int taskSuccessCallBack(@Param("map")Map map,@Param("param")String param);
    //如果是出库任务，更新货位信息
    public int issueUpdateShelvesCode(@Param("issueMap")Map map);
    //入库任务完成，更新货位占用
    public int successInputShelvesCode(@Param("successMap")Map map);
    //移库任务完成，更新旧货位信息
    public int successMoveShelvesCodeChangeFirst(@Param("inputMap")Map map);
    //移库任务完成，更新新货位信息
    public int successMoveShelvesCodeChangeSeconde(@Param("secondMap")Map map);
    //接收wcs反馈信息任务设备故障
    public int taskFailCallBack(@Param("wmsTaskId")Long wmsTaskId,@Param("command") int command);

    public int aceptTask(int command, int taskType,Long wmsTaskId,String palletCode,String startCode,String endCode);

    //分配货位时，更新立体库信息表，信息
    public int updateShelvesCode(String ShelvesCode,String palletCode);

    /**
     * 叫箱成功后更新立体库信息
     * @param ShelvesCode
     * @return
     */
    public int updateSslShelvesByShelvesCode(@Param("ShelvesCode") String ShelvesCode);


    /**
     * 根据物料编码，查询货位信息
     * @param itemCode
     * @return
     */
    public List<HashMap<String,Object>>getShelvesCodeByWorkbinCode(@Param("itemCode")String itemCode);


    //yebo 2023-04-07 判断箱子是否在货架上面
    int searchPalletIsOnShelves(@Param("palletCode") String palletCode);


    /**
     * 新增一条数据
     * @param msSslShelvesDTO
     * @return
     */
    public int insertMsSslShelvesDTO(@Param("bean") MsSslShelvesDTO msSslShelvesDTO);

    /**
     * 批量新增数据
     * @param msWpToolBasicDTO
     * @return
     */
    public int batchInsertMsSslShelvesDTO(List<MsSslShelvesDTO> msWpToolBasicDTO);

    /**
     * 根据条件查询数据
     * @param
     * @return
     */
    List<HashMap> searchMsSslShelvesByParams(@Param("bean") HashMap queryMap,@Param("isTest")String isTest);

    /**
     * 根据物料箱编码查询数据
     * @param id
     * @return
     */
    public MsSslShelvesDTO searchMsSslShelvesDTOById(String id);

    /**
     * 更新数据
     * @param
     * @return
     */
    public int updateMssSslShelves(@Param("map") HashMap map);

    /**
     * 删除数据
     * @param id
     * @return
     */
    public int deleteMsSslShelvesDTO(String id);

    //修改缓存箱状态
    public int updateIsEmpty(String workbinCode);

    //查询是否为空箱，便于移库时记录箱子状态
    public HashMap searchIsEmputy(@Param("map")Map map);

    //判断是否有货物在货架上
    public HashMap searchWorkbinShevels(@Param("map")Map map);

    //插入同步数据临时表
    public int insertInfoSynchroni(@Param("infoMap")HashMap map);

    //调用同步信息存储过程
    public HashMap callInfoSynchroni(@Param("callMap")HashMap map);
}
